<?xml version="1.0" encoding="UTF-8"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1">
<jsp:directive.page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" />
<jsp:directive.page import="java.util.Iterator, cult.ticketing.bean.*" />
<jsp:output omit-xml-declaration="no" doctype-root-element="html" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" />
<jsp:include page="templates/include_header.html" />

<jsp:text><![CDATA[<html>
<head>
<title>Cult Ticketing System</title>
<script type="text/javascript">
    //This function is from phoenixshade http://www.codingforums.com/showthread.php?t=109368
    function bgcolorElementsByClassName(classname,color) {
        var regex=new RegExp("\\b"+classname+"\\b");
        var alltags=document.getElementsByTagName("*");
        for (i=0; i<alltags.length; i++) {
            name=alltags[i].className;
            if (name.match(regex)){
                alltags[i].onmouseover='true';
                alltags[i].onclick='true';
                alltags[i].onmouseout='true';
                alltags[i].bgColor=color;

            }
        }
    }
</script>

<link href="]]></jsp:text><jsp:expression>request.getContextPath()</jsp:expression><jsp:text><![CDATA[/css/style.css" rel="stylesheet" type="text/css" />
<link href="]]></jsp:text><jsp:expression>request.getContextPath()</jsp:expression><jsp:text><![CDATA[/css/movie.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="container">
]]></jsp:text>
<jsp:include page="templates/include_menu.jsp" />
<jsp:include page="templates/search.jsp" />

<jsp:text><![CDATA[<div id="main">
        <div id="content">
        <div id="head_image">
        	<div id="slogan"><strong>Cult Ticketing System -- Now Showing</strong><br />
       	    </div>
            <div id="under_slogan_text">
                <br /><br /><br /><br />

            </div>
          </div>

         <div id="left">]]></jsp:text>
            <jsp:include page="templates/login.jsp" />
            <jsp:include page="templates/calendar.jsp" />
         <jsp:text><![CDATA[</div>

         <div id="right">
            <h1>Seating Plan</h1>
            <p>&nbsp;</p>]]></jsp:text>

             <jsp:scriptlet>
                 int[][] seatingPlan = (int[][])request.getAttribute("seatingPlan");
                 int[][] seatAvailability = (int[][])request.getAttribute("seatAvailability");
                 int seatingPlanWidth = Integer.parseInt(request.getAttribute("seatingPlanWidth").toString());
                 int houseHeight = Integer.parseInt(request.getAttribute("houseHeight").toString());
            </jsp:scriptlet>

            <jsp:text><![CDATA[
            <form name="seatingPlan" id="seatingPlan" method="post" action="]]></jsp:text><jsp:expression>request.getContextPath()</jsp:expression><jsp:text><![CDATA[/index.do">
            <input type="hidden" name="todo" id="todo" value="showCostSummary" />
            <input type="hidden" name="purchasedSeatIndex" id="purchasedSeatIndex" value="" />
            <table cellspacing="10">
                <caption>screen</caption><tbody>]]></jsp:text>

            <jsp:scriptlet>
                int BOOKED_SEAT = 1;
                int NOT_AVAILABLE_SEAT = 2;
                int NOT_A_SEAT = -1;
                for(int i=0; i&lt;houseHeight; i++) {
                    int rowNum = i+65;
            </jsp:scriptlet>
                <jsp:text><![CDATA[
                <tr>]]></jsp:text>
                    <jsp:scriptlet>
                    for (int j=0; j&lt;seatingPlanWidth; j++) {
                        if (seatAvailability[i][j] == NOT_A_SEAT){</jsp:scriptlet>
                            <jsp:text><![CDATA[
                            <td style="width:40"><b>&#]]></jsp:text><jsp:expression>rowNum</jsp:expression><jsp:text><![CDATA[;</b></td>]]></jsp:text>
                        <jsp:scriptlet>
                        }
                        else if (seatAvailability[i][j] == NOT_AVAILABLE_SEAT){</jsp:scriptlet>
                            <jsp:text><![CDATA[
                            <td style="width:'20';background-color:grey">]]></jsp:text><jsp:expression>seatingPlan[i][j]</jsp:expression><jsp:text><![CDATA[</td>]]></jsp:text>
                        <jsp:scriptlet>
                        }
                        else if (seatAvailability[i][j] == BOOKED_SEAT){</jsp:scriptlet>
                            <jsp:text><![CDATA[
                            <td style="width:'20';background-color:red">]]></jsp:text><jsp:expression>seatingPlan[i][j]</jsp:expression><jsp:text><![CDATA[</td>]]></jsp:text>
                        <jsp:scriptlet>
                        }
                        else {</jsp:scriptlet>
                            <jsp:text><![CDATA[
                            <td class="selectable" bgColor="lawngreen" style="width:'20'" onmouseover="this.bgColor='yellow'" onmouseout="this.bgColor='lawngreen'" onclick="this.bgColor='red';this.onmouseout='false';this.onmouseover='false';document.getElementById('purchasedSeatIndex').value=document.getElementById('purchasedSeatIndex').value + ]]></jsp:text><jsp:expression>i</jsp:expression><jsp:text><![CDATA[ + ',' + ]]></jsp:text><jsp:expression>j</jsp:expression><jsp:text><![CDATA[ + ';';this.onclick='false'">]]></jsp:text>
                                <jsp:expression>seatingPlan[i][j]</jsp:expression>
                            <jsp:text><![CDATA[</td>]]></jsp:text>
                        <jsp:scriptlet>}
                    }</jsp:scriptlet>
                <jsp:text><![CDATA[</tr>]]></jsp:text>
            <jsp:scriptlet>}</jsp:scriptlet>
             <jsp:text><![CDATA[</tbody>
            <input type="text" name="test" id="test" value="" />
            <tfoot>
                <input type="submit" value="Buy Ticket" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'"/>
                <input type="button" value="Clear" onclick="bgcolorElementsByClassName('selectable','lawngreen');document.getElementById('purchasedSeatIndex').value=''" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'"/>
                <input type="button" value="TEST" onclick="document.getElementById('test').value=document.getElementById('purchasedSeatIndex').value" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'"/>
             </tfoot>
            </table></form>
            ]]></jsp:text>
      
        <jsp:text><![CDATA[
        </div>
	</div>
</div>
</div>]]></jsp:text>
<jsp:include page="templates/include_footer.html" />
<jsp:text><![CDATA[</body>
</html>
]]></jsp:text>
</jsp:root>
